


function MessageBoxHandler () {
    var me = this,
    
    dimmer = document.createElement("div");
    
    me.msgBoxes = [];
    me.queue = [];
    me.showing = false;
    
    document.body.appendChild(dimmer);
    me.dimmer = dimmer;
    
    dimmer.className = "dimmer";
}

MessageBoxHandler.prototype = {
    
    add : function(msgBox) {
        this.msgBoxes.push(msgBox);
    },
    
    show : function(msgBox, callback) {
        var me = this;
        if(!me.showing) {
            
            me.showing = true;
            
            me.showDimmer();
            
            msgBox.showInDom(callback);
            
        }else{
            me.queue.push(msgBox);
        }
        
    },
    
    hide : function(msgBox) {
        
        this.showing = false;
        this.hideDimmer();
        msgBox.hideInDom();
        
    },
    
    
    showDimmer : function() {
        var style = this.dimmer.style;
        style.display = "block";
        style.opacity = "0.4";
    },
    
    hideDimmer : function() {
        var style = this.dimmer.style;
        style.display = "none";
        style.opacity = "0.0";
    }
    
};